<template>
  <div>
    <template>
      <div slot="header" class="clearfix" style="text-align: center;line-height: 30px">
        <h3>用户订单管理</h3>
      </div>

      <el-table
          :data="orderData"
          border
          style="width: 100%">
        <el-table-column
            fixed
            prop="ordercode"
            label="订单号">
        </el-table-column>
        <el-table-column
            prop="pay"
            label="支付方式">
        </el-table-column>
        <el-table-column
            prop="userid"
            label="用户号">
        </el-table-column>
        <el-table-column
            prop="ordertime"
            label="下单时间">
        </el-table-column>
        <el-table-column
            prop="totalmoney"
            label="总金额">
        </el-table-column>
        <el-table-column
            fixed="right"
            label="商品详情">
          <template slot-scope="scope">
            <el-button @click="handleClick(scope.row)" type="button" size="small">商品详情</el-button>
          </template>
        </el-table-column>
      </el-table>

      <el-dialog
          :visible.sync="dialogVisible"
          width="45%">
        <UserOrderGoods ref="child1" @closeDialog="closeWin" :usercodeTag="usercodeTag"></UserOrderGoods>
      </el-dialog>

      <div class="block">
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="pageNum"
            :page-sizes="[6, 8, 10, 12]"
            :page-size="100"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total">
        </el-pagination>
      </div>
    </template>
  </div>
</template>

<script>
import UserOrderGoods from "@/components/UserOrderGoods";

export default {
  name: "OrderCopy",
  components:{
    UserOrderGoods
  },
  data(){
    return{
      pageNum: 1,
      pageSize: 6,
      total: '',
      orderData: [],
      dialogVisible: false,
      usercodeTag:''
    }
  },
  mounted() {
    this.init()
  },
  methods:{
    init(){
      let url = '/csc/user-order/selectOnePageOrder/'+ this.pageNum + "/" + this.pageSize
      this.$axios.get(url).then(r=>{
        console.log(r.data)
        this.orderData = r.data.records
        this.total = r.data.total
      })
    },
    handleSizeChange(val) {
      this.pageSize = val
      this.init()
    },
    handleCurrentChange(val) {
      this.pageNum = val
      this.init()
    },
    handleClick(row){
      this.usercodeTag = row.orderid
      this.dialogVisible = true
      this.$refs.child1.init(this.usercodeTag);
    },
    closeWin(){
      this.init()
      this.dialogVisible = false
    }
  }
}
</script>

<style scoped>

</style>